/*
 * GNU GENERAL PUBLIC LICENSE v2
 * 
 * Developers: Alan Audette, Oguz Bastemur
 */
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using ICSharpCode.SharpZipLib.Zip;
using System.IO;

namespace SqlDatabaseBackup
{
    public class ArchiveManager
    {
        /// <summary>
        /// Default Constructor
        /// </summary>
        public ArchiveManager() { }

        /// <summary>
        /// Archives a list of files into a single .zip file
        /// </summary>
        /// <param name="archivePath">Complete path of the archive (.zip) file</param>
        /// <param name="filesToArchive">List of files to include in the archive</param>
        public static void ArchiveFiles(string archivePath, ArrayList filesToArchive)
        {
            // Create the zip archive file
            ZipFile archive = ZipFile.Create(archivePath);
            
            // Notify the archive that we will be updating
            archive.BeginUpdate();

            // Add each file to the archive
            foreach (string file in filesToArchive)
                archive.Add(file);
            
            // Tell the archive to commit our changes
            archive.CommitUpdate();

            // Close the archive
            archive.Close();
        }
    }
}
